<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumToTaskTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('task', function (Blueprint $table) {
            //
            $table->tinyInteger('source')->default('0')->comment('漏洞来源，来源于漏洞提交者的source');
            $table->string('description', 225)->default(' ')->comment('副标题');
            $table->string('vuls_number', 225)->default(' ')->comment('漏洞编号');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumn('task', 'source')) {
            Schema::table('task', function (Blueprint $table) {
                $table->dropColumn(['source']);
            });
        }
        if (Schema::hasColumn('task', 'description')) {
            Schema::table('task', function (Blueprint $table) {
                $table->dropColumn(['description']);
            });
        }
        if (Schema::hasColumn('task', 'vuls_number')) {
            Schema::table('task', function (Blueprint $table) {
                $table->dropColumn(['vuls_number']);
            });
        }
    }
}
